package com.joe.test;

import javax.swing.*;
import java.awt.*;

public class Project2 extends JFrame {
    wdmb4 mb = null;

    public Project2() {
        mb = new wdmb4();
        mb.setBackground(Color.yellow);//使用super语句，这样的话这句代码也可以执行
        this.add(mb);
        this.setTitle("");
        this.setSize(600, 600);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    public static void main(String[] args) {

        Project2 pro = new Project2();
    }

}

class wdmb4 extends JPanel {

    public void paint(Graphics g) {
        super.paint(g);
        System.out.println("print方法被运行");
    }
}